import pygame
import g
from animation import Hitbox

class GameObject:
	def __init__(self, image, owner, x, y):
		self.x = x
		self.y = y
		self.name = "INSTANTIATE SUBCLASS"
		self.image = image
		self.facing = "LEFT"
		self.owner = owner
		self.attackAlreadyHit = False

	def blockKnockback(self):
		pass

	def hit(self, other):
		g.gGame.killObject(self)
		
	def gethit(self, other):
		pass

	def update(self, shouldUpdateAnimation):
		pass

	def render(self, screen, scroll):
		image = self.image
		if self.facing == "RIGHT":
			frame = pygame.transform.flip(image, True, False)
		screen.blit(image, (self.x - self.image.get_width()/2 - scroll[0], self.y - self.image.get_height()/2 - scroll[1]))

	def getAbsBoxFrame(self):
		return [Hitbox((self.x - self.image.get_width()/2, self.y - self.image.get_height()/2, self.image.get_width(), self.image.get_height()),{"type":1})]
		
	def renderHitbox(self, screen, scroll):
		pygame.draw.rect(screen, (255, 0, 0),(self.x - self.image.get_width()/2 - scroll[0], self.y - self.image.get_height()/2 - scroll[1], self.image.get_width(), self.image.get_height()), 1)

class Projectile(GameObject):
	def __init__(self, image, owner, x, y, xVelocity, yVelocity):
		GameObject.__init__(self, image, owner, x, y)
		self.xVelocity = xVelocity
		self.yVelocity = yVelocity
		
	def update(self, shouldUpdateAnimation):
		self.x += self.xVelocity
		self.y += self.yVelocity

class Hadouken(Projectile):
	def __init__(self, image, owner, x, y, xVelocity):
		Projectile.__init__(self, image, owner, x, y, xVelocity, 0)
		self.name = "Hadouken"
		if xVelocity > 0:
			self.facing = "RIGHT"
			
objects = { "hadouken" : Hadouken }
